﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.Library;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Model;


namespace IHISCETeim.Web.MachineSys.UserModel
{
    public partial class USpecialCaseList : EasyUIPageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.查看, Permission.修改, Permission.新增, Permission.删除 };
            }
        }
        protected override string DWZRef
        {
            get
            {
                return "USpecialCaseList";
            }
        }


        #region 属性 (查询条件)


        protected string CommonFiled
        {
            get
            {
                return GetRequestValue<string>("CommonFiled", "");

            }
        }
        protected string CommonValue
        {
            get
            {
                return GetRequestValue<string>("CommonValue", "");

            }
        }

        protected string CardType
        {
            get
            {
                return GetRequestValue<string>("CardType", "");
            }
        }


        /// <summary>
        /// 排序字段 值为 id
        /// </summary>
        protected override string orderField
        {
            get
            {
                return string.IsNullOrEmpty(base.orderField) ? "SCID" : base.orderField;
            }
        }
        /// <summary>
        ///  排序方式 desc或 asc
        /// </summary>
        protected override string orderDirection
        {
            get
            {
                return string.IsNullOrEmpty(base.orderDirection) ? "DESC" : base.orderDirection;
            }
        }


        protected override string SQLSort
        {
            get
            {
                return (orderField + " " + orderDirection);
            }
        }

        #endregion



        protected string GetWhereSql()
        {
            string wheresql = QueryOperatorsEnumHelper.ConvertCommonOperator(CommonFiled, QueryOperatorsEnum.包含, CommonValue);




            if (!CardType.IsEmptyOrNull())
            {
                if (string.IsNullOrEmpty(wheresql))
                    wheresql = " CardType='" + CardType + "'";
                else
                    wheresql += " and CardType='" + CardType + "'";
            }


            return wheresql;
        }

        protected override string query()
        {
            DataTable dts = null;
            dts = USpecialCaseController.GetPagination(GetWhereSql(), pageNum, numPerPage, SQLSort, ref TotalCount);
            return ToDataGridJson(dts, TotalCount, null).ToString();

        }
    }
}